#pragma once
#include "common.h"
#include "RadixTree.h"

class PageCache
{
private:
	SpanList _pageSpanLists[Npages];
	static PageCache _instance;
	//std::unordered_map<size_t, Span*> _idSpanMap;
	TCMalloc_PageMap2<BitNum - Nshift> _idSpanMap;
	
	//ObjectPool<Span> _objPool;
public:
	std::mutex _pageMtx;

	static PageCache* GetInstance()
	{
		return &_instance;
	}

	Span* NewSpan(size_t num);
	Span* MapObjectToSpan(void* obj);
	void ReleaseSpanToPageCache(Span* span);

};